
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)



const routes = [
    { path: '/', redirect: '/index' },
    { 
      path: '/index',
       component: () => import('../view/index.vue'),
       children:[
         { path: 'banners',meta: { title: '轮播图管理'} ,component:() => import ('../view/shouye/banner') },
         { path: 'category', component:() => import ('../view/shouye/category') },
         { path: 'recommend', component:() => import ('../view/shouye/recommend') },
         { path: 'fenlei', component:() => import ('../view/shangpin/fenlei') },
         { path: 'brand', component:() => import ('../view/shangpin/brand') },
         { path: 'goods', component:() => import ('../view/shangpin/goods') },
         { path: 'news', component:() => import ('../view/xinwen/news') },
         { path: 'examle', component:() => import ('../view/xinwen/examle') },
         { path: 'user', component:() => import ('../view/xinwen/user') },
         { path: 'sku', component:() => import ('../view/shangpin/sku') },

       ]
       },
    { path: '/login', component:() => import ('../view/login.vue') },
  ]

const router = new VueRouter({
  // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
//   history: VueRouter.createWebHashHistory(),
  routes, // `routes: routes` 的缩写
})
router.beforeEach((to, from, next) => {
  next()
})

export default router